package com.newzqxq.koalamoney.ui.fragment;

import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.newzqxq.koalamoney.R;
import com.newzqxq.koalamoney.common.BaseFragment;
import com.newzqxq.koalamoney.ui.activity.AssetsIncomeActivity;
import com.newzqxq.koalamoney.ui.activity.FeedbackActivity;
import com.newzqxq.koalamoney.ui.activity.MyFinancialActivity;
import com.newzqxq.koalamoney.ui.activity.OpenBankManagerActivity;
import com.newzqxq.koalamoney.ui.activity.RechargeActivity;
import com.newzqxq.koalamoney.ui.activity.SettingActivity;
import com.newzqxq.koalamoney.ui.activity.TakeMoneyActivity;
import com.newzqxq.koalamoney.ui.activity.VouchersActivity;
import com.newzqxq.koalamoney.utils.StatusBarUtil;
import com.newzqxq.koalamoney.widget.dialog.CustomDialog;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 我的
 */

public class MyFragment extends BaseFragment {

    private static final int RP = 1;
    private static final int IR = 2;
    private static final int EC = 3;
    @BindView(R.id.my_withdrawal)
    TextView my_withdrawal;


    @Override
    protected View initView(LayoutInflater inflater, ViewGroup container) {
        return inflater.inflate(R.layout.fragment_my, container, false);
    }

    @Override
    protected void initData() {
        StatusBarUtil.transparencyBar(getActivity());
    }

    /**
     * @param view
     * @OnClick 我的理财  设置   提现  意见反馈 充值  总资产  累计收益
     */
    @OnClick({R.id.my_financial, R.id.my_setting, R.id.my_withdrawal, R.id.my_feedback, R.id.tvRecharge,R.id.my_total_assets,R.id.my_accumulated_earnings})
    void MyFragmentOnClicks(View view) {
        switch (view.getId()) {
            case R.id.my_financial://我的理财
                startActivity(new Intent(getActivity(), MyFinancialActivity.class));
                break;
            case R.id.my_setting://设置
                startActivity(new Intent(getActivity(), SettingActivity.class));
                break;
            case R.id.my_withdrawal://提现
                Withdrawal();
                break;
            case R.id.my_feedback://意见反馈
                startActivity(new Intent(getActivity(), FeedbackActivity.class));
                break;
            case R.id.tvRecharge://充值
                startActivity(new Intent(getActivity(), RechargeActivity.class));
                break;
            case R.id.my_total_assets://总资产
                Intent intent1 = new Intent(getActivity(), AssetsIncomeActivity.class);
                intent1.putExtra("showItem",1);
                startActivity(intent1);
                break;
            case R.id.my_accumulated_earnings://累计收益
                Intent intent2 = new Intent(getActivity(), AssetsIncomeActivity.class);
                intent2.putExtra("showItem",2);
                startActivity(intent2);
                break;
        }
    }

    @OnClick({R.id.my_red_packet, R.id.my_interest_rates, R.id.my_experience})
    void VouchersOnClicks(View view) {
        switch (view.getId()) {
            case R.id.my_red_packet:
                Intent rp= new Intent(getActivity(), VouchersActivity.class);
                rp.putExtra("NUM",RP);
                startActivity(rp);
                break;
            case R.id.my_interest_rates:
                Intent ir= new Intent(getActivity(), VouchersActivity.class);
                ir.putExtra("NUM",IR);
                startActivity(ir);
                break;
            case R.id.my_experience:
                Intent ec= new Intent(getActivity(), VouchersActivity.class);
                ec.putExtra("NUM",EC);
                startActivity(ec);
                break;
        }
    }

    private void Withdrawal() {
        final CustomDialog dialog = new CustomDialog(getActivity());
        dialog.setOKButton("去开通", new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dialog.dismiss();
                startActivity(new Intent(getActivity(), OpenBankManagerActivity.class));
            }
        });
        dialog.setCancelButton(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dialog.dismiss();
                //目前到提现页面
                startActivity(new Intent(getActivity(), TakeMoneyActivity.class));
            }
        });
        dialog.show();
    }

}

